<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>会议添加</title>
    <?php PrintPageHead(); ?>
    <link href="../resource/css/hermes.css" rel="stylesheet">
    <link href="../resource/js/calendar/calendar-blue.css" type="text/css" rel="stylesheet">
    <script src="../resource/js/calendar/calendar.js" type="text/javascript"></script>
    <script src="../resource/js/hermes.js"></script>
    <style type="text/css">
       .form_d{
           width:500px;
           margin: 20px auto;
       }
    </style>
    <?php
    if (!array_key_exists("公众号ID",$_SESSION)) {
        header("Location:back.php");
    }
    $bm=new C后台管理员();

    $课程id ='';
    if(isset($_REQUEST['id']))$课程id = $_REQUEST['id'];

    if($课程id){
        $内容=pdo()->selectOne("SELECT a.* FROM `会议表`a  where id=".$_REQUEST['id'].";");

    }


    ?>
</head>
<body>

<!-- 配置文件 -->
<script type="text/javascript" src="../ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="../ueditor/ueditor.all.min.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('container', {
        toolbars: [
            [ 'fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|','link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'simpleupload', 'insertimage', 'emotion', 'scrawl', 'attachment', 'map', 'gmap', 'insertframe']
        ],
        autoHeightEnabled: true,
        autoFloatEnabled: true
    });
</script>

<div class="container-fluid">
    <?php include_once 'back_header.php'; ?>
    <div class="panel panel-primary">
        <div class="panel-heading text-center"><h3 class="panel-title"><?php if(isset($内容))echo "编辑";else echo "添加";?>会议</h3></div>
        <?php  if(!$内容){?>
        <div class="form_d">
            <form action="" method="post">
                您的姓名:<input type="text" name="name" id="namese" style="width: 120px">
                <input type="button" onclick="selectshow()" name="select" value="搜索用户">

            </form>
        </div>
        <div class="form_d"><span style="width: 180px">用   户:</span>
            <div id="xianshi">

                    <input type="radio" checked="checked" value="<?=$内容['操作人id']?>" name="专家id"> <?=$内容['name']?>
            </div>

            <?php  }?>


            <form action="" method="post" enctype="multipart/form-data">
            <div class="form_d">
                <input type="hidden" value="<?=@$内容['操作人id']?>" id="autor" name="操作人id">
                <input name="id" value="<?=@$内容['id']?>" type="hidden">
                <input name="图片" value="<?=@$内容['图片log']?>" type="hidden">
                <div class="form_d"><span>会议名称:</span>
                    <textarea rows="1" cols="40" name="name"><?=$内容['name']?></textarea>
                       </div>
                <div class="form_d"><span>会议时间:</span><input style="width: 80%;" type="text" name="会议时间" value="<?=@$内容['会议时间']?>"></div>
            <div class="form_d"><span>会议地点:</span><textarea style="width: 80%;" type="text" name="会议地点" value=""><?=@$内容['会议地点']?></textarea></div>
                <div class="form_d"><span>主办单位:</span><input style="width: 80%;" type="text" name="主办单位" value="<?=@$内容['主办单位']?>"></div>
                <div class="form_d"><span>会议主页面:</span><input style="width: 80%;" type="text" name="下一步" value="<?=@$内容['下一步']?>"></div>
                <div class="form_d"><span>最多报名人数:</span><input style="width: 80%;" type="text" name="max_register" value="<?=@$内容['max_register']?>"></div>
                <div class="form_d"><span>状态:</span>
                <select name="状态">
                    <?php if($内容['状态']=='发布'):?>
                    <option >待发布</option><option selected>发布</option>
                    <?php else: ?>
                    <option >待发布</option><option selected>发布</option>
                    <?php endif ?>
                </select>
                </div>
                <div class="form_d"><span>上传会议列表图片:<input style="width: 80%;" type="file" name="pic"></span></div>
                <div class="form_d"><span>子栏目(用-隔开):</span><!-- 加载编辑器的容器 -->
                    <textarea rows="3" cols="30" name ="子栏目"  placeholder="会议报名-会议简介-专家简介-会议群"><?=$内容['子栏目']?></textarea>
                </div>
                <div class="form_d"><span>会议报名路径:</span><!-- 加载编辑器的容器 -->
                    <textarea rows="2" cols="30" name ="会议报名" placeholder=""><?=$内容['会议报名']?></textarea>
                </div>
                <div class="form_d"><span>会议简介路径:</span><!-- 加载编辑器的容器 -->
                    <textarea rows="2" cols="30" name ="会议简介" placeholder="选填"><?=$内容['会议简介']?></textarea>
                </div>
                <div class="form_d"><span>专家简介路径:</span><!-- 加载编辑器的容器 -->
                    <textarea rows="2" cols="30" name ="专家简介" placeholder="选填"><?=$内容['专家简介']?></textarea>
                </div>
                <div class="form_d"><span>会议议程路径:</span><!-- 加载编辑器的容器 -->
                    <textarea rows="2" cols="30" name ="会议议程" placeholder="如会议课程安排"><?=$内容['会议议程']?></textarea>
                </div>

                </div>



            <div class="form_d"><input id="tijiao" type="submit" name="okn" value="提交">

                <a href="../back.php?state=back14meet_shipin_list">查看历史</a> </div>

        </form>

</div>
    </div>

</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="../resource/js/jquery-1.11.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../resource/js/bootstrap.min.js"></script>

</body>
</html>
<script src="../resource/js/jquery-1.11.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../resource/js/bootstrap.min.js"></script>
<script language="JavaScript">
    function selectshow(){
        var name= document.getElementById("namese").value;
        $.post('back.php?state=BackSellerAjax',{name:name,'businessFlag':'ac查找用户'},function(data) {
            document.getElementById('xianshi').innerHTML='';
            document.getElementById("xianshi").innerHTML=data;

        });

    }
    $(function(){
//    $("#fasong").click(function(){
//        $(this).attr('hidden',true);
//    });
//    $("#fasong2").click(function(){
//        $(this).attr('hidden',true);
//    });


        $("#tijiao").click(function(){
            var q= $('input[name="专家id"]:checked').val();
            if(q.length!=0){
                $('#autor').val(q);
            }

            $(this).attr('hidden',true);
        });
    })

</script>
<?php

if(isset($_POST['okn'])){
    unset($_REQUEST['okn']);
    unset($_REQUEST['state']);
    if($_REQUEST['name']==''){
        echo "<script>alert('请认真填写信息!');</script>";
    }else {
        //图片处理开始
        //此处比较乱，用cui数据中心就需要openid ，绕了一圈得到openid
        $用户openID = pdo()->selectOne("select openID from 用户 WHERE id=" . $_REQUEST['操作人id']);
        $bm = new CUI数据中心('Seller17Shipin_Lessons', $用户openID['openID']);

        if ($_FILES['pic']['name']) {
            $图片路径 = 'cache/text_img/';
            $图片 = $bm->上传图片($_FILES, $图片路径);
        }
        if ($图片 == '文件上传类型错误!' || $图片 == '图片上传失败!' || $图片 == '图片大小超过1M!') {
            echo "<script>alert('上传失败');</script>";
            return false;

        } else{
            $_REQUEST['图片log'] = $图片;
        }
        //图片处理结束
        if ($内容) {

            $dos = new  Do会议表();
            $_REQUEST['图片log']=empty($_REQUEST['图片log'])?$_REQUEST['图片']:$_REQUEST['图片log'];
            unset($_REQUEST['图片']);
            $res1 = pdo()->update($dos->tableName(), $_REQUEST, array("id" => $_REQUEST['id']));

            if ($res1) {


                echo "<script>alert('修改成功');location.replace('back.php?state=back14meet_list');</script>";
            } else {

                echo "<script>alert('修改失败或没有修改任何信息');</script>";
            }
        } else {

            unset($_REQUEST['id']);
            unset($_REQUEST['图片']);
            $dos = new  Do会议表();



           // $_REQUEST['图片log']=$
            $res = pdo()->insert($dos->tableName(), $_REQUEST);
            if ($res) {

                echo "<script language='javascript'>alert('添加成功!');location.replace('back.php?state=back14meet_list');</script>";

            } else {

                echo "<script>alert('添加失败');</script>";
            }


        }
    }

}
?>
